<!-- Imports -->
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Hashtable"%>
<%@page import="canss.supports.basic"%>
<%@page import="canss.supports.Makequery_select"%>
<!-- Initiation -->
<%
response.setContentType("text/html; charset=UTF-8");
canss.web.controls.WebDBControl webdbcontrol = null;
webdbcontrol = (webdbcontrol==null)?new canss.web.controls.WebDBControlBean():webdbcontrol;
%>
<!-- Preparing inputs -->
<%
String _debug = basic.IIf(request.getParameter("_debug"), "");
String _mid = basic.IIf(request.getParameter("_mid"), "");
int i=0;
%>
<!-- Query Compilation -->
<%
/*
 FROM  WHERE canssModule_mid='120' LIMIT 0,100
*/

Makequery_select query = new Makequery_select()
.Select("canssModule_mid, canssModule_name, canssEvent_EventID, canssEvent_EventName, canssEvent_EventSeqnum, canssEvent_Timestamp")
.PushFrom("viewEventLog")
.PushWhere(String.format("canssModule_mid='%s'", _mid))
.Limit("0,100");

if(basic.isNotEmpty(_debug))//debug msg
	out.write(query.toString());

Iterator<String[]> iter = null;
Hashtable<String, Integer> hash = null;
try
{
	LinkedList<String[]> res = webdbcontrol.Select(query);
	iter = res.iterator();
	if(iter.hasNext())
	{
		String[] curhashtmp = iter.next();
		hash = new Hashtable<String, Integer>(curhashtmp.length);
		for(i=0; i<curhashtmp.length; i++)
			hash.put(curhashtmp[i], i);
	}
}catch(Exception e)
{
	e.printStackTrace();
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="canss.encoder.DBStringEncoder"%>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta content="ko" http-equiv="Content-Language" />
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>KAIST-CANSS EventLog Detail View</title>
	<link href="design/mainframe.css" rel="stylesheet" type="text/css" />
	<link href="design/forms.css" rel="stylesheet" type="text/css"/>
	<link href="design/content.css" rel="stylesheet" type="text/css"/>
	<link href="design/layout.css" rel="stylesheet" type="text/css"/>
	<style type="text/css">
	.style1 {
		text-align: center;
		color: #FFFFFF;
		border-style: solid;
		border-width: 1px;
		padding: 1px 4px;
		background-color: #248CFC;
	}
	.style2 {
		border-style: solid;
		border-width: 1px;
	}
	img.button {
		cursor:pointer;
	}
	index
	{
		cursor:default;
	}
	input
	{
		border: #1EB1f9 2px dotted;
	}
	</style>
	<script type="text/javascript" src="lib/jquery-1.2.6.min.js"></script>
	<script type="text/javascript" src="lib/jquery.ui-1.6.4.js"></script>
	<script type="text/javascript" src="lib/jquery.form.js"></script>
	</head>
	<body >
	
	<script type="text/javascript">
		//docall("POST", "svtXSLT", "_xslpath=XSLTEventLogAdmin.xsl&_xmlpath=" + "<%=DBStringEncoder.EncString("svtOPAdminEventLog?" + "_mid="+request.getParameter("_mid"))%>");
	</script>
	<div id="overlay2" style="z-index: 150; position: absolute; width: 100%; display: none; height: 100%; top: 0px; left: 0px;">
		<img width="40" height="40" id="loadingImage" style="position: absolute; top:50%; left:50%;" src="design/img/loading.gif" complete="complete"/>
	</div>

	<div id="divbody1" style="position: absolute; width: 100%; height: 100%; top: 0px; left: 10px;">
		<table class="datatable">
			<tbody>
				<tr>
					<th scope='col'>No</th>
					<th scope='col'>Module ID</th>
					<th scope='col'>Module Name</th>
					<th scope='col'>Event Name</th>
					<th scope='col'>Timestamp</th>
					<th scope='col'>View Details</th>
				</tr>
				<%
				if(basic.isNotEmpty(_mid))
				{
					i=1;
					while(iter!=null && iter.hasNext())
					{
						String[] cur = iter.next();
						out.write("<tr>");
						out.write(String.format("<td scope='col'><center>%s</center></td>", i));
						out.write(String.format("<td>%s</td>", cur[hash.get("canssModule_mid")]));
						out.write(String.format("<td>%s</td>", cur[hash.get("canssModule_name")]));
						out.write(String.format("<td>%s</td>", cur[hash.get("canssEvent_EventName")]));
						out.write(String.format("<td>%s</td>", cur[hash.get("canssEvent_Timestamp")]));
						out.write(
								"<td>"+
								String.format(" <form id='frm_eventlogdetail_%s' action='getEventLogDetail.jsp' method='post' target='pop_evenglogdetail'><a href='#' onclick=\"", i)+
								String.format("   var frm=$('#frm_eventlogdetail_%s');", i)+
								"   window.open('', 'pop_evenglogdetail','width=740,height=850');"+
								"   frm.submit();"+
								"   return false;\">View Detail</a>"+
								String.format("  <input type='hidden' name='_mid' value='%s' />", cur[hash.get("canssModule_mid")]) +
								String.format("  <input type='hidden' name='_eventid' value='%s' />", cur[hash.get("canssEvent_EventID")]) +
								String.format("  <input type='hidden' name='_seqnum' value='%s' />", cur[hash.get("canssEvent_EventSeqnum")]) +
								String.format("  <input type='hidden' name='_timestamp' value='%s' />", cur[hash.get("canssEvent_Timestamp")]) +
								" </form>"+
								"</td>");
						out.write("</tr>");
						i++;
					}
				}else
				{
					%>
				<tr>
					<td />
					<td />
					<td />
					<td />
					<td />
					<td />
				</tr>
					<%
				}
				%>
				
			</tbody>
		</table>
	</div>
	
	</body>
</html>



